from tortoise import fields, models

class SimulationResult(models.Model):
    simulation_result_id = fields.IntField(pk=True)
    env_param = fields.ForeignKeyField('models.EnvParameter', related_name='simulation_results', on_delete=fields.CASCADE)
    time_point = fields.DatetimeField()
    battery_energy = fields.DecimalField(max_digits=10, decimal_places=4, description="当前电池电量")
    solar_power = fields.DecimalField(max_digits=10, decimal_places=4, description="太阳能供电量")
    grid_power = fields.DecimalField(max_digits=10, decimal_places=4, description="国网供电量")
    total_power = fields.DecimalField(max_digits=10, decimal_places=4, description="总供电量")
    wind_power = fields.DecimalField(max_digits=10, decimal_places=4, description="风能供电量")
    solar_cost = fields.DecimalField(max_digits=10, decimal_places=4, description="太阳能购电费用")
    wind_cost = fields.DecimalField(max_digits=10, decimal_places=4, description="风能购电费用")
    grid_cost = fields.DecimalField(max_digits=10, decimal_places=4, description="国网购电费用")
    solar_emission = fields.DecimalField(max_digits=10, decimal_places=4, description="太阳能碳排放")
    wind_emission = fields.DecimalField(max_digits=10, decimal_places=4, description="风能碳排放")
    grid_emission = fields.DecimalField(max_digits=10, decimal_places=4, description="国网碳排放")
    total_maps: fields.ReverseRelation["SimulationResultTotalMap"]

    class Meta:
        table = "simulation_result"

    def __str__(self):
        return f"SimulationResult {self.simulation_result_id} at {self.time_point}"